<?php 
/**
 * Mobile
 * ========================================================
 * Copy 2010-2012 iswu
 * Web:http://sirius.ccaeo.com
 * ========================================================
 * Author:iswu
 * Date:${date}
 */
//防止恶意调用
if (!defined('IN_TG')){
    exit('Access Defined!');
}

//设置字符编码集
header('Content-Type:text/html; charset = utf-8');

//转换绝对路径常量
// echo substr(dirname(__FILE__), 0, 47);
define('ROOT_PATH', substr(dirname(__FILE__), 0, -8));

//创建一个自动转义状态的常量
define('GPC', get_magic_quotes_gpc());  

//拒绝低PHP版本
if (PHP_VERSION < '4.1.0'){
    exit('PHP_VERSION is too low!');
}

/*
//执行耗时
// echo microtime(); //微秒数  时间戳
$_mtime = explode(' ', microtime());
// print_r($_mtime);//打印数组
$_start_time = $_mtime[1] + $_mtime[0];//加载开始时间
usleep(1000000);//睡眠函数
$_mtime = explode(' ', microtime());
$_end_time = $_mtime[1] + $_mtime[0];//加载结束时间

echo $_end_time - $_start_time;//打印时间差
*/
//引入核心函数库
require ROOT_PATH.'includes/global.func.php';
require ROOT_PATH.'includes/mysql.func.php';
// $_start_time = _runtime();
/*
<p>本程序执行耗时：<?php echo $_end_time - $_start_time?>秒</p>
*/ 
// usleep(1000000);
/*
$_end_time = _runtime();
echo $_end_time - $_start_time;
*/
//define('START_TIME', _runtime()); //定义全局变量
$GLOBALS['start_time'] = _runtime();//定义超级全局变量

//数据库连接
// define('DB_HOST', 'sql313.ccaeo.com');
// define('DB_USER', 'cca_18899157');
// define('DB_PWD', 'Xintong2010');
// define('DB_NAME', 'cca_18899157_mobile');

define('DB_HOST', 'localhost');
define('DB_USER', 'root');
define('DB_PWD', 'root');
define('DB_NAME', 'mobile');

/*
//创建数据库连接
$_conn = @mysql_connect(DB_HOST, DB_USER, DB_PWD) or die ('数据库连接失败!');

//选择一款数据库
mysql_select_db(DB_NAME) or die ('指定的数据库不存在！');

//选择字符集
mysql_query('SET NAMES UTF8') or die ('字符集错误！');
*/

//初始化数据库
_connect();       //连接MYSQL数据库
_select_db();     //选择指定的数据库
_set_names();     //设置字符集

//做测试
//$query = mysql_query("SELECT tg_username FROM tg_user WHERE tg_username='小天2狼星'") or die ('SQL错误！');
//echo $query;  //打印资源句柄 Resource id #6
//echo mysql_fetch_array($query); //打印 Array
//print_r(mysql_fetch_array($query,MYSQL_ASSOC));

// if(mysql_fetch_array($query,MYSQL_ASSOC)){
// 	echo '有重复';
// }else{
// 	echo '没重复';
// }

/*
//短信提醒
$_message = _fetch_array("SELECT COUNT(tg_id) AS count FROM tg_message WHERE tg_state=0 AND tg_touser='{$_COOKIE['username']}'");
if (empty($_message['count'])) {
	// $_message_html = '<strong class="noread"><a href="member_message.php">(0)</a></strong>';
	$GLOBALS['message'] = '<strong class="noread"><a href="member_message.php">(0)</a></strong>';
} else {
	// $_message_html = '<strong class="read"><a href="member_message.php">('.$_message['count'].')</a></strong>';
	$GLOBALS['message'] = '<strong class="read"><a href="member_message.php">('.$_message['count'].')</a></strong>';
}
// print_r($_message['count']);

//网站系统设置初始化
if (!!$_rows = _fetch_array("SELECT 
															tg_webname,
															tg_article,
															tg_blog,
															tg_photo,
															tg_skin,
															tg_string,
															tg_post,
															tg_re,
															tg_code,
															tg_register 
												FROM 
															tg_system 
											 WHERE 
															tg_id=1 
												 LIMIT 
															1"
)) {
	$_system = array();
	$_system['webname'] = $_rows['tg_webname'];
	$_system['article'] = $_rows['tg_article'];
	$_system['blog'] = $_rows['tg_blog'];
	$_system['photo'] = $_rows['tg_photo'];
	$_system['skin'] = $_rows['tg_skin'];
	$_system['post'] = $_rows['tg_post'];
	$_system['re'] = $_rows['tg_re'];
	$_system['code'] = $_rows['tg_code'];
	$_system['register'] = $_rows['tg_register'];
	$_system['string'] = $_rows['tg_string'];
	$_system = _html($_system);

	//如果有skin的cookie那么就替代系统数据库的皮肤   会与数据库系统设置皮肤冲突
	if ($_COOKIE['skin']) {         
		$_system['skin'] = $_COOKIE['skin'];
	}
} else {
	exit('系统表异常，请管理员检查！');
}
*/

?>
